-- The listening port.
port = 10004

require("remoteCalls");

-- Got a login packet.
newCharId = 10000;
function gotLoginPacket(conn, name, pass)
    if name == "test" and pass == "pass" then
        local id = newCharId;
        newCharId = newCharId + 1;
        local mobID = 0;
        local x = 0;
        local y = 0;
        local z = 0;
        local red = 243/256;
        local green = 204/256;
        local blue = 130/256;
        local alpha = 1;
        odysis.addCharacter(x, y, z, mobID, id, red, green, blue, alpha);
        odysis.setClientCharID(conn, id);
        odysis.sendLoginOKPacket(conn);
    else
        odysis.sendLoginFailPacket(conn);
    end
    clientDebugMessage(conn, "This is a test");
end

-- Got a move request packet.
function gotMoveRequestPacket(conn, direction)
    local char = odysis.getClientCharID(conn);
    if char > 0 then
        odysis.moveCharacter(char, direction);
    end
end

function serverDebugMessageImp(conn, msg)
    print(conn .. ": " .. msg);
end
